2010-03-29 23 views
-1

我要調用一個用戶定義的函數調用的UIView methdods

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 

這種方法是否有可能?如果是的話,怎麼樣? PL。引導我。

回答

1

此方法應爲custom UIViewController來實現,例如

@interface MyViewController : UIViewController { 
    ... 
} 
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)io; 
@end 

@implementation MyViewController 
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)io { 
    return io != UIInterfaceOrientationPortraitUpsideDown; 
} 
@end 
+0

但如何調用該函數在.m文件?如果我們通過[selfAutorotateToInterfaceOrientation]來實現,那麼我們需要通過爭論。應該通過什麼爭論bcoz它是UIInterfaceOrienttion類型? – mindfreak 2010-03-30 10:14:14

+0

@mindfreak它會被系統自動調用。 – kennytm 2010-03-30 10:46:42