2011-10-27 38 views
7

我得到的Xcode 4.3下運行我的應用程序時,上面的主題行警告。從枚舉類型「UIBarButtonSystemItem」不同的枚舉類型隱式轉換「UIBarButtonItemStyle」 - iPad的 - 的iOS5

這裏是有問題的代碼:

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:map]; 

    UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" 
                    style:UIBarButtonSystemItemDone target:self action:@selector(removeCurrent)]; 
    map.navigationItem.rightBarButtonItem = rightButton; 

    [self presentModalViewController:navigationController animated:YES]; 

誰能幫助?

謝謝!

回答

13

UIBarButtonSystemItemDone應該UIBarButtonItemStyleDoneinitWithBarButtonSystemItem: - - 實際上可能對你更好,因爲它會返回一個本地化的完成按鈕,而不是你現在有固定的文本系統項目在不同的init方法使用。

+2

+1,完全正確的答案。 –

+0

把這個鏈接回答完成。 [式必須是在UIBarButtonItemStyle定義的常量(http://developer.apple.com/library/ios/#documentation/uikit/reference/UIBarButtonItem_Class/Reference/Reference.html)和[UIBarButtonItemStyle的typedef](HTTP: //developer.apple.com/library/ios/#documentation/uikit/reference/UIBarButtonItem_Class/Reference/Reference.html) –