[英]UITableview delegate is not being called
我已經為表創建了一個插座屬性。
@屬性(強,非原子)IBOutlet UITableView * tableView;
我已經在界面中添加了委托
的UITableViewDelegate
4.注冊代表:
tableView.delegate=self;
並添加了tableview的所有功能,這些功能通常在以下情況下就可以實現:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
還有其他所有。 這些函數在開始時沒有被調用。
我在這里想念什么?
您缺少tableView的dataSource。 這些方法出現在數據源上,而不是在委托上。
設置tableView.dataSource=self;
以及,您應該很好。
UITableView有兩個委托, delegate
和dataSource
因為它們處理不同的焦點區域。
您可能缺少以下內容之一。
1.確保已通過Xibs或代碼將數據源和TableView的代理設置為當前視圖控制器。
2.請在下面的標題中提及您必須實現的協議。
@interface ViewController()<UITableViewDataSource,UITableViewDelegate>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.