2015-01-06 15 views
0

我想添加個人資料圖片到我的應用程序,當用戶註冊時使用解析,但是我不想創建一個全新的ViewController來執行此操作。在委託shouldBeginSignUp,我有基本的:不完成解析註冊直到圖片被選中

- (BOOL)signUpViewController:(PFSignUpViewController *)signUpController shouldBeginSignUp:(NSDictionary *)info { 

    BOOL informationComplete = YES; 
    // loop through all of the submitted data 
    for (id key in info) { 
     NSString *field = [info objectForKey:key]; 
     if (!field || field.length == 0 || ![signUpController.signUpView.additionalField.text containsString:@" "]) { // check completion 
      informationComplete = NO; 
      break; 
     } 


    } 

    // Display an alert if a field wasn't completed 
    if (!informationComplete) { 
     [[[UIAlertView alloc] initWithTitle:@"Missing Information" 
            message:@"Make sure you fill out all of the information, including first & last name!" 
            delegate:nil 
          cancelButtonTitle:@"ok" 
          otherButtonTitles:nil] show]; 
    } 

    return informationComplete; 

} 

,直到所有領域都完成這將托起註冊過程。我想要做的是在點擊註冊後,讓它彈出一個UIActionSheet,要求選擇個人資料照片或拍攝新照片。拍攝照片後,它會將其添加到PFUser。你會如何建議這樣做?

+0

你卡在哪裏? –

+0

如果未選擇圖片,則返回false,然後閱讀有關UIImagePickerController(https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIImagePickerController_Class/index.html) – danh

回答

0

您需要始終從該委託方法返回no,儘管我不能100%確定您可以在保存(需要測試)之前爲用戶設置自定義文件/引用。

一旦您的驗證通過,您仍然會返回NO,但會觸發您的操作以選擇圖像。選擇圖像後,您將忽略所有內容,然後使用PFUser手動完成註冊過程(您可能需要手動創建用戶並迭代註冊控制器的字段以使用用戶選擇填充它)。