मैं यूआईटीबल व्यू के पाद लेख में UIButton प्रदर्शित करना चाहता हूं (शीर्षलेख के लिए बिल्कुल वही होना चाहिए)।UITableView tableFooterView अजीब आकार बदलना
इस कोड को मेरी TableViewController की viewDidLoad में है:
UIButton *footerShareButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[footerShareButton setFrame:CGRectMake(10, 0, 70, 50)];
NSLog(@"%f", footerShareButton.frame.size.width);
[self.tableView setTableFooterView:footerShareButton];
NSLog(@"%f", footerShareButton.frame.size.width);
NSLog(@"%f", self.tableView.tableFooterView.frame.size.width);
हालांकि, इस कोड काम नहीं करता। बटन की चौड़ाई बहुत बड़ी है, यह 320 है। (ऊंचाई हालांकि सही है।) पहला एनएसएलओजी 70, दूसरा और तीसरा आउटपुट 320 आउटपुट करता है। तो ऐसा लगता है कि setTableFooterView विधि अजीब रूप से बटन का आकार बदलती है।
मैं तालिका पाद लेख के रूप में सेट करने से पहले एक और UIView में UIButton रख कर इस समस्या का समाधान कर दिया है:
UIButton *footerShareButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[footerShareButton setFrame:CGRectMake(10, 0, 70, 50)];
UIView *aView = [[UIView alloc] initWithFrame:CGRectMake(10, 0, 70, 50)];
[aView addSubview:footerShareButton];
[self.tableView setTableFooterView:aView];
[aView release];
यह काम करता है, बटन सही चौड़ाई है।
हालांकि, मुझे समझ में नहीं आता कि पहला कोड नमूना क्यों काम नहीं करता है। क्या कोई समझा सकता है?
हाँ, यह है कि यह है, यह देखने के लिए मैं भी बनाया आकार बदलने करता है, मैं सिर्फ नोटिस नहीं किया था। धन्यवाद। मुझे लगता है कि यह दस्तावेज़ों में उल्लिखित होना चाहिए जो तालिका को सेट करते हैं FooterView प्रॉपर्टी दृश्य का आकार बदलती है, जो मुझे कुछ समय बचा लेती। – avf