objective c - xcode ios - image in tableview section header -


यह मेरा कोड है:

  - (UIView *) tableView: (UITableView *) तालिका दृश्य दृश्य ForHeaderInSection: (NSInteger) अनुभाग {UIImage * myImage = [UIImage imageNamed: @ "photo.png"]; UIImageView * imageView = [[UIImageView alloc] initWithImage: myImage]; ImageView.frame = CGRectMake (10,10,60,60); यदि (अनुभाग == 0) {वापसी 0; } और अगर (अनुभाग == 1) {वापसी 0; } और अगर (अनुभाग == 2) {वापसी 0; } और अगर (अनुभाग == 3) {वापसी 0; } और अगर (अनुभाग == 5) {returnView; } और {वापसी 0; }}  

तो छवि दिखाई देती है लेकिन समस्या यह है कि imageView.frame काम नहीं कर रहा, फोटो आकार हैडर ऊंचाई के बराबर दिखाई दे रहा है, कैसे कर सकते हैं कि मैं ठीक

जब आप tableView लागू: viewForHeaderInSection: आप विधि (UITableView *) tableView heightForHeaderInSection: (NSInteger) खंड - heightForHeaderInSection:: वांछित हैडर ऊंचाई वापस जाने के लिए विधि (CGFloat) tableView

  भी  tableView को लागू करना चाहिए {If (अनुभाग == 5) {वापसी 70; } और {वापसी 0; }  

और अपने viewForHeaderInSection विधि बनाने के किया जा सकता है बेहतर:

  - (UIView *) tableView: (UITableView *) tableView viewForHeaderInSection: (NSInteger) अनुभाग {अगर (खंड == 5) {UIImage * myImage = [UIImage imageNamed: @ "photo.png"]; UIImageView * imageView = [[UIImageView alloc] initWithImage: myImage]; ImageView.frame = CGRectMake (10, 10, 60, 60); UIView * दृश्य = [[UIView alloc] initWithFrame: CGRectMake (0, 0, 320, 70)]; [ऐडस्यूब दृश्य: छवि देखें]; वापसी दृश्य; } और {वापसी शून्य; }}  

Comments

Popular posts from this blog

php - Select box validation (in laravel) -

pandas - Iterate on Groupby Object's fields -

Creating a sparse matrix in Matlab with a specified number of independent Bernoulli +-1 nonzero entries -