0
再次原諒我,如果我不清楚,我只能在昨天啓動iOS開發。從UIPickerView中檢索行索引,並在if語句中使用它
所以我有一個應用程序將發送信息到特定的電子郵件地址。 我已經包含了一個pickerview,並用一個信息數組,5或6個不同的類別填充它。我想要做的是能夠根據選擇器視圖中選擇的類別更改電子郵件的收件人。
到目前爲止,我有,但selectedRowInComponent
似乎並沒有工作。
- (IBAction)sendFinalItem:(UIButton *)sender {
NSLog(@"send button pressed");
if ([self.pickerView selectedRowInComponent:(0)])
{
MFMailComposeViewController *mailcontroller = [[MFMailComposeViewController alloc] init];
[mailcontroller setMailComposeDelegate:self];
NSString *email [email protected]"[email protected]";
NSArray *emailArray = [[NSArray alloc] initWithObjects:email, nil];
[mailcontroller setToRecipients:emailArray];
[mailcontroller setSubject:@"[Urgent]Potential Job, iPhone snapped"];
[self presentViewController:mailcontroller animated:YES completion:nil];
[mailcontroller setMessageBody:notesTextView.text isHTML:NO];
}
修復代碼格式。 – rmaddy
將此添加到頂部。 NSLog(@「Selected index%d」,[self.pickerView selectedRowInComponent:0]);並看看它是否返回正確的索引 –