Tag: cocoa touch

如何从一个iPhone设备发送推送通知到另一个?

是否有可能从一个iPhone设备发送推送通知到另一个? 如果是的话,那么你可以告诉我怎么办?

ViewController实现UITextFieldDelegate时出错

在我的ViewController类中实现UITextFieldDelegate时,在文本字段中input第一个字符时会引发以下错误: -[MyViewController respondsToSelector:]: message sent to deallocated instance… 所以,我试着创build一个单独的类(只inheritanceNSObject)并实现UITextFieldDelegate。 猜猜看,它完美的工作。 然而,这引起了一些其他问题,因为我必须做很多丑陋的跨class级交stream,我想避免。 以下是我的应用程序委托代码的相关部分: @interface RMSAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> @property (nonatomic, retain) UIViewController* myViewController; @end @implementation MyAppDelegate @synthesize myViewController; – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { myViewController = [[MyViewController alloc] initWithNibName:@"MyView" bundle:nil]; [self.window setRootViewController:myViewController]; [self.window makeKeyAndVisible]; return YES; } @end ..这是什么显示: @interface MyViewController : UIViewController <UITextFieldDelegate> @property […]

可能将NSmanagedObject移动到另一个NSManagedContext?

我有两个NSManagedContext的,一个父母和一个孩子,我用于并发。 指定像这样: self.managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; self.backgroundContext = [[NSManagedObjectContext alloc] initWithConcurrencyType: NSPrivateQueueConcurrencyType]; self.backgroundContext.parentContext = self.managedObjectContext; 在我的一个视图控制器中,我调用了这个方法: [Stream followingStreamForUser:self.user fromDictionary:dict inManagedObjectContext: [AppController sharedAppController].backgroundContext]; 调用此方法会导致以下错误: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Illegal attempt to establish a relationship '[…]' between objects in different contexts 看起来像self.user不在我的backgroundContext 。 我不知道是否有可能将我的self.user对象移动到我的backgroundContext或者如果可以看到我的用户对象被添加到上下文X的位置和时间。

对NSDictionary的SIGABRT objectAtIndex:无法识别的select器

我在这里有一个奇怪的错误。 我有一个名为__ImageData的数组: static NSArray *__ImageData = nil; NSString *path = [[NSBundle mainBundle] pathForResource:@"ImageData" ofType:@"plist"]; NSData *plistData = [NSData dataWithContentsOfFile:path]; NSString *error; NSPropertyListFormat format; _ImageData = [NSPropertyListSerialization propertyListFromData:plistData mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&error]; 当我NSLog出arrays的内容,我得到这个输出: 2012-08-23 16:36:35.573 CAT[28814:c07] { "Item 0" = { height = 7121; name = Map1; width = 8556; }; "Item 1" = { height = […]

将UIPicker添加到文本字段

我有一个表格视图,我必须在一些单元格中显示文本字段。 当用户单击文本字段时,我希望select器视图以0到99之间的整数值显示。一旦用户在选取器视图中select了该项目,则需要在该特定文本字段上显示相同的内容。 任何帮助将真诚感激。

以编程方式为应用程序内购买添加导出types的UTI

我想有一个In-App Purchase ,允许我的用户从电子邮件和其他应用程序导入文件。 为此,我需要将Exported Type UTI密钥添加到我的.plist文件中。 问题是,我不想这样做,直到用户做了In-App Purchase 。 一旦他们这样做,那么我想要允许这个function。 是否有可能以编程方式将Exported Type UTI添加到我的.plist? 还是有另一种首选的方式来提供使用In-App Purchasing ?

NSFetchRequest setPropertiesToGroupBy:返回匹配的所有实体吗?

我正在开发一个应用程序的iOS,我找不到有关新的NSFetchRequest setPropertiesToGroupBy:方法的文档。 我有一堆与多个实体B对象有关系的实体A对象。 我想获取匹配特定模式的所有实体B对象,并将它们按实体A分组。这样我就不必为每个实体A单独获取数据库了。结果理想情况下是结构化的,以便我可以迭代等于实体As的组,然后将具有与来自一个获取请求的模式匹配的所有实体Bs。 我可以看到setPropertiesToGroupBy:方法应该让我通过反B-> A关系进行分组,并返回一个NSDictionaries数组。 但这是否意味着NSArray每个项目都对应于实体A的一个组? 而且相应的NSManagedObject子类可以在NSDictionary某处find?

我如何确定iOS应用程序的HTTP请求的用户代理?

我有一个iOS应用程序,下载一个XML文件使用: NSURL *queryURL = [NSURL URLWithString:query]; NSData *xmlData = [[NSData alloc] initWithContentsOfURL:queryURL]; 打电话给第三方,所以我不控制服务器。 第三方需要知道用户代理是什么(他们正在根据用户代理优化提要) 我的问题是如何确定我的用户代理是什么? 我没有专门设置,并没有find任何文件。

Autoresizingmask立即覆盖最初设置的框架(创build一个不同的和错误的布局)

我正在尝试configuration我的一个视图。 我可以正确设置尺寸,但是当我添加自动调整掩码时,它会立即改变尺寸。 – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. UIScrollView* scrollView = [[UIScrollView alloc] initWithFrame: CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height – self.tabBarController.tabBar.frame.size.height – self.navigationController.navigationBar.frame.size.height – 10)]; // -10 so I know it's not being hidden under the tabbar scrollView.backgroundColor = [UIColor greenColor]; // easy recognition scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight | […]

UITextView textviewshouldendediting永远不会被调用

我有这样的UITextView设置: UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(10, 40, 280, 240)]; [textView setBackgroundColor:[UIColor greenColor]]; [textView setFont:[UIFont fontWithName:@"MyriadPro-Regular" size:13]]; [textView setTextColor:[UIColor blackColor]]; [textView setText:@"Your Message…."]; [textView setBackgroundColor:[UIColor clearColor]]; [textView setDelegate:self]; [textView setReturnKeyType:UIReturnKeyDone]; 我期待,当用户按下键盘上的“完成”button,这个方法将被调用(我已经实现): – (BOOL)textViewShouldEndEditing:(UITextView *)textView { NSLog(@"called"); [textView resignFirstResponder]; return YES; } 但这种方法永远不会被调用..我做错了什么? 谢谢。