मुझे गतिशील रूप से आबादी वाले UIViewTable के ऊपर तुरंत एक बटन डालना होगा। यह सही प्रथम कक्ष (पंक्ति 0) पॉप्युलेट नहीं, बल्कि हेडर क्षेत्र का उपयोग करने लगता है, इसलिए मैं UITableViewDelegate विधि का उपयोग प्रोग्राम के रूप में एक UIView एक UIButton युक्त बनाने के लिए: के रूप में नीचे, दर्शायाUITableView शीर्षलेख के शीर्षलेख में UIButton जोड़ना
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0,0, 320, 44)] autorelease]; // x,y,width,height
UIButton *reportButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
reportButton.frame = CGRectMake(80.0, 0, 160.0, 40.0); // x,y,width,height
[reportButton setTitle:@"rep" forState:UIControlStateNormal];
[reportButton addTarget:self
action:@selector(buttonPressed:)
forControlEvents:UIControlEventTouchDown];
[headerView addSubview:reportButton];
return headerView;
}
हालांकि, बटन को आवश्यक स्थान नहीं दिया गया है (मुझे उम्मीद है कि हेडर की ऊंचाई 44 तर्क का पालन करेगी)।
यहां क्या गलत है? मुझे यह जोड़ना चाहिए कि UITableView एक अलग XIB- फ़ाइल में बनाया गया है।
ऐसा नहीं था। धन्यवाद। – maralbjo