如何通过宏检测设备模型?我曾经使用过这样的东西但模拟器上的结果总是IS_IPHONE_5
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_5 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0)
#define IS_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0)
#define IS_IPHONE_6PLUS (IS_IPHONE && [[UIScreen mainScreen] nativeScale] == 3.0f)
#define IS_IPHONE_6_PLUS (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 736.0)
#define IS_RETINA ([[UIScreen mainScreen] scale] == 2.0)
Run Code Online (Sandbox Code Playgroud) 在iPad App中我正在使用UISplitViewController.当应用程序以纵向模式启动时,我需要强制显示主弹出窗口.
现在我正在使用此代码,它在iOS 5.0上运行良好.
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
if ([[[AppDelegate sharedAppDelegate] splitViewController] respondsToSelector:[[[AppDelegate sharedAppDelegate] btnMenu] action]]) {
[[[AppDelegate sharedAppDelegate] splitViewController] performSelector:[[[AppDelegate sharedAppDelegate] btnMenu] action]];
}
}
Run Code Online (Sandbox Code Playgroud)
但是在iOS 5.1(使用新型主弹出窗口)中,行为似乎是随机的.有时弹出窗口全屏显示,有时效果很好.
5.1的一些建议?
我创造了一个 UIActionSheet
UIActionSheet * action = [[UIActionSheet alloc]initWithTitle:@""
delegate:self
cancelButtonTitle: @"cancel"
destructiveButtonTitle: @"OK"
otherButtonTitles: nil];
[action showInView:self.view];
[action release];
Run Code Online (Sandbox Code Playgroud)
在取消按钮的事件中,UIActionSheet
我想要触发一个事件UIBarButtonItem
,这在我看来.
我的问题是如何在UIActionSheet
委托方法中触发按钮事件(不触摸按钮)