Objective-C无需相机界面即可拍摄照片的简单方法。 只需从相机获取图片并保存到文件

我无法find一个没有相机界面拍照的简单方法。 我只需要从相机中获取图片并将其保存到文件。

如何将丰富的文本粘贴到UITextView?

我的应用程序允许用户通过单击某些格式button来将文本格式化为UITextView的格式,这些button将属性应用于文本视图的属性文本属性。 我想让用户从一个UITextView复制他们的格式文本,并使用标准的剪贴板和标准剪切/复制/粘贴菜单粘贴到另一个。 目前,如果我从UITextView中复制格式化的文本,并将其粘贴到邮件应用程序中的新邮件中,格式化将被保留 – 因此,格式化文本的复制将自动进行。 但是,如果我将格式化的文本粘贴到另一个UITextView中,则只会显示纯文本。 通过遵循iOS文本编程指南中的“粘贴select”部分,我可以覆盖UITextView的粘贴方法并拦截粘贴的内容: – (void)paste:(id)sender { UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; NSLog(@"types available: %@", [pasteboard pasteboardTypes]); for (NSString *type in [pasteboard pasteboardTypes]) { NSLog(@"type %@ (%@): %@", type, NSStringFromClass([[pasteboard valueForPasteboardType:type] class]), [pasteboard valueForPasteboardType:type]); } } 这告诉我,粘贴板包含以下格式的内容:com.apple.rtfd,public.rtf,public.text和“Apple Web Archive粘贴板types”。 文本的值是纯文本string,rtf的值是一个RTFstring,两个Apple格式的值是NSData。 这是我卡住的地方。 如何将这些项目中的一个从粘贴板数据转换为为UITextView设置的属性string? 或者更好的是,有没有办法将UITextViewconfiguration为在粘贴时自动接受格式化文本,与复制时自动提供格式化文本的方式相同?

如何添加表格视图节标题与下标?

在我的应用程序中,我有一个表格视图,到目前为止我已经使用storyboard(我已经添加了部分:rows:cells等等,全部通过storyboard),唯一的改变是编程式的添加一个UIButton作为部分标题通过执行: – (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { if (section == 2) { UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 64)]; UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button1 setTitle:@"Hydro Volume" forState:UIControlStateNormal]; button1.frame = CGRectMake(62.5, 5, 205, 44); [view addSubview:button1]; [button1 addTarget: self action: @selector(buttonClicked:) forControlEvents: UIControlEventTouchDown]; return view; } return nil; } 我目前的困境是,我不得不添加一个包含下标的节标题,即:H2O 我无法直接在故事板检查器中添加下标,有人可以告诉我怎么做到这一点? 我回顾了这个问题 ,但它不是我正在寻找的,因为我需要能够将其添加到我的部分标题。

与Instagram照片地图的照片地图

我正在尝试创build一个类似Instagrams照片地图的照片地图。 照片地图: http : //i.stack.imgur.com/B0wDa.jpg 我怎样才能得到的图像(从parsing加载)的注释,就像上面的截图? 到目前为止,这就是MapViewController.m [PFGeoPoint geoPointForCurrentLocationInBackground:^(PFGeoPoint *geoPoint, NSError *error) { PFQuery *query = [PFQuery queryWithClassName: @"HomePopulation"]; [query whereKey:@"geopoint" nearGeoPoint:geoPoint withinKilometers:3000]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (!error) { for (PFObject *object in objects) { PFGeoPoint *thePoint = [object objectForKey:@"geopoint"]; latitude = thePoint.latitude; longitude = thePoint.longitude; NSLog(@" Hej %f, %f", latitude, longitude); […]

Plist数组NSArray没有对象

所以我search了,之前已经成功地读过了,但是却遇到了这个问题。 我有一个plist,是一串string。 我没有得到任何对象被读入数组。 我成功地做了这个在另一个控制器的字典。 所以这里是我的代码。 // Open plist and get brands NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"brands" ofType:@"plist"]; NSFileManager *fileManager = [NSFileManager defaultManager]; if ([fileManager fileExistsAtPath:plistPath]) { NSLog(@"The file exists"); } else { NSLog(@"The file does not exist"); } _brands = [NSArray arrayWithContentsOfFile:plistPath]; _catList = [[[NSMutableArray alloc] initWithCapacity:[_brands count]] autorelease]; 这是我的plist。 请注意_brands数组被定义为NSArray *品牌,属性设置为非primefaces,只读,并被合成为品牌= _brands。 <?xml […]

解散和代表UIImagePickerController摄像头iOS8.4的问题

编辑问题从零开始恢复。 我有一个ViewController A有一个导航栏button,它呈现了一个UIImagePickerControllertypes的UIImagePickerControllerSourceTypeCamera ,我们将调用这个ViewController B. 在A的didFinishPickingMediaWithInfo:方法中,我将呈现ViewController C. 现在问题从这里开始。 当我终于到达C时 ,我们可以看到视图堆栈显然是: A -modal-> B -modal-> C 从C我然后有一个“后退”button出现在导航栏应该带我回到B. 但是,由于B是一个UIImagePickerController,我不能重用它,它必须被解雇。 所以,要做到这一点,我目前有以下方法执行C :上的“返回”button: – (IBAction)backOnPost:(UIBarButtonItem *)sender { [self.view endEditing:YES]; UINavigationController *LogControl = [self.storyboard instantiateViewControllerWithIdentifier:@"LogControl"]; RGLogViewController *logView = (RGLogViewController *)LogControl.topViewController; [UIView animateWithDuration:0.25 animations:^{ self.presentingViewController.view.alpha = 0; [self.presentingViewController dismissViewControllerAnimated:NO completion:nil]; [self.presentingViewController.presentingViewController dismissViewControllerAnimated:NO completion:nil]; } completion:^(BOOL finished){ [logView setBoolBackPushed]; }]; } 上面的代码的工作原理是通过驳回B和C来让我回到A. […]

UISearchbar中的UItextField在iOS 7升级后失败

我有一个UITextField的UISearchBar这是工作,直到iOS 7升级,现在失败在这一行: UITextField *textfield=(UITextField*)[[searchBar subviews] objectAtIndex:1]; 任何想法如何解决这个问题? 谢谢 // search bar searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 190.0, 44.0)]; searchBar.autoresizingMask = UIViewAutoresizingFlexibleWidth; UIView *searchBarView = [[UIView alloc] initWithFrame:CGRectMake(90.0, 0.0, 230.0, 44.0)]; searchBarView.autoresizingMask = 0; searchBar.delegate = self; searchBar.layer.borderColor=[UIColor whiteColor].CGColor; UITextField *textfield=(UITextField*)[[searchBar subviews] objectAtIndex:1]; [searchBarView addSubview:searchBar]; self.navigationItem.titleView = searchBarView;

上传到App Store的最低Xcode版本(截至2016年2月)

我正在将更新上传到app store中的现有应用。 我已经使用Xcode 6,4,现在在最新的Xcode(7.2)中,iPad中的多任务支持是一个新的补充和位代码支持。 归档文件是以前版本的两倍,并且在构build时还会显示“启动文件警告”。 我可以使用Xcode 6.4本身还是新的Xcode 7.2。

iOS:TapGestureRecognizer问题

所以我有一个应用程序,就像一个照片库,我正在实现用户删除图像的能力。 这里是设置:我有9 UIImageViews,imageView,imageView2等。我也有一个“编辑”button,tapGesture行动方法。 我将一个Tap Gesture识别器拖到IB的视图中,并将其附加到每个UIImageView。 我还将tapGesture操作方法附加到每个UIImageView。 理想情况下,我希望方法只有在按下“编辑”button时才能激活。 当用户点击编辑,然后点击他们想要删除的图片,我想要一个UIAlertView出现,问他们是否确定要删除它。 这是我正在使用的代码: – (IBAction)editButtonPressed:(id)sender { editButton.hidden = YES; backToGalleryButton.hidden = NO; tapToDeleteLabel.hidden = NO; } – (IBAction)tapGesture:(UITapGestureRecognizer*)gesture { UIAlertView *deleteAlertView = [[UIAlertView alloc] initWithTitle:@"Delete" message:@"Are you sure you want to delete this photo?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil]; [deleteAlertView show]; if (buttonIndex != [alertView cancelButtonIndex]) { UIImageView *view = […]

更快的if语句:如果`variable`是“value”或“value”

你怎么能在一个论点中与多种可能性进行比较? 例: if ((integer == 2) || (integer == 5)) if ((string == "hello") || (string == "dolly)) 如果你能写这样的话,会节省很多代码: if (integer == (2 || 5)) if (string == ("hello" || "dolly"))