我想做一個ToDo列表應用程序,我不能爲我的生活似乎弄清楚如何使文本框的輸入文本進入框與一個勾選框,我可以更改爲完成。如何使用UITextField將信息輸入到UITableView?
任何人都可以幫助我嗎?我剛剛開始使用Xcode,請解釋爲什麼/如何以這種方式爲未來學習。多謝你們!
應用渲染(我想使)
目前在Xcode(我有什麼至今)
我想做一個ToDo列表應用程序,我不能爲我的生活似乎弄清楚如何使文本框的輸入文本進入框與一個勾選框,我可以更改爲完成。如何使用UITextField將信息輸入到UITableView?
任何人都可以幫助我嗎?我剛剛開始使用Xcode,請解釋爲什麼/如何以這種方式爲未來學習。多謝你們!
應用渲染(我想使)
目前在Xcode(我有什麼至今)
您需要創建附加的IBAction爲按鈕。因此,當你點擊按鈕並將輸入的文本存儲在數組中的UItextfield中時,它會被調用,並且您將使用該數組在表中添加行。
例如考慮代碼:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [dataArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
}
[cell.textLabel setText: [dataArray objectAtIndex:indexPath.row];
return cell;
}
-(IBAction)addCity:(id)sender
{
[tableView beginUpdates];
[dataArray addObject:@"City"];
NSArray *paths = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:[dataArray count]-1 inSection:1]];
[[self tableView] insertRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationTop];
[tableView endUpdates];
}
我對此非常失望...... – dotyy
這應該去哪裏?在.h或@implementation下的.m中?我已經在.xib中設置了一切,但沒有編碼。這是我的.h的圖像。 http://gyazo.com/c3e1acda7abaf648115f1e7d7e7d578d這裏是我的.m http://gyazo.com/8cc8c995edfe9add339184a508e1fcb7 – dotyy
的圖像嘿,先讓你的基本清楚。閱讀創建UITableView,UIButton,UITextField和全部的基本教程。如何創建這些及其方法和委託的IBAction和Property。 檢查此鏈接的教程http://www.raywenderlich.com –
到目前爲止,我還沒有嘗試過任何重要的東西。我試着按照關於向表格添加項目的教程,但是它使用通知警報來輸入它,並且無法使其相關。 – dotyy