这是我第一次在Cocoa-touch框架上使用web服务,我在控制台上成功地从web服务中获取了数据,但当我尝试通过数组在TableView上传递数据时,它什么也做不到。我觉得问题是,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; 该方法不会传递用于编译的编译器。即使它可以工作,它也会将所有带有标记的数据转换为表格文本,因为使用了:cell.textLabel.text = [myDataCell objectAtIndex:indexPath.row];
如何在具有指定字段的动态cell.text上使用它们?任何帮助都将不胜感激。
#import "ViewController.h"
#import "REQService.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize sorguTextField,sorguButton,sorguLabelOutput,name;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)getOutput:(id)sender {
REQService* service = [REQService service];
service.logging = YES;
[service NumaradanIsimALL:self action:@selector(NumaradanIsimALLHandler:) msisdn:sorguTextField.text username: @"xxx" password:@"xxxxxxxxx"];
myDataCell = [[NSMutableArray alloc ] initWithObjects:myData, nil];
}
#pragma notes - View Tables
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
cell = [tableView dequeueReusableCellWithIdentifier:@"myCell"];
if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"myCell"];
}
cell.textLabel.text = [myDataCell objectAtIndex:indexPath.row];
}
@end发布于 2012-10-30 18:44:46
看起来您还没有在视图控制器类中实现web服务响应处理程序NumaradanIsimALLHandler方法。在你的代码中实现这个方法,一旦你在这个方法中得到一个响应,将它赋值给myDataCell对象并重新加载表视图(例如[tableView reloadData]);
在本例中,您只需轻触一个按钮即可进行异步web服务调用,由于表视图委托将在视图加载后立即被调用,因此您需要在NumaradanIsimALLHandler处理程序方法中重新加载表视图。
https://stackoverflow.com/questions/13136436
复制相似问题