English 中文(简体)
无法增加地貌模式中技工团的宽度
原标题:not able to increase width of UILabel in landscape mode

I had made an iPad application, in that I have tableView whose name is crollTableView, in my tableView I am creating two labels in each cell of row, whose name is capitalLabel and stateLabel, in portrait mode,

我现在想增加我对地貌模式的描述,

here is code snippet,

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

if(tableView==crollTableView){
        static NSString *CellIdentifier=@"Cell";
        static NSInteger StateTag = 1;
        static NSInteger CapitalTag = 2;
        UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if(cell == nil){

            // cell.backgroundColor=[UIColor yellowColor];
            cell=[[[UITableViewCell alloc]initWithFrame:CGRectZero reuseIdentifier:CellIdentifier]autorelease];
            CGRect frame;
            frame.origin.x = 0; 
            frame.origin.y = 0;
            frame.size.height = 70;
            frame.size.width = 650;


            UILabel *capitalLabel = [[UILabel alloc] initWithFrame:frame];
            capitalLabel.tag = CapitalTag;
            capitalLabel.opaque = FALSE;
            capitalLabel.font=[UIFont systemFontOfSize:20.0];
            [cell.contentView addSubview:capitalLabel];


            frame.origin.x += 680;
            UILabel *stateLabel = [[UILabel alloc] initWithFrame:frame];
            stateLabel.tag = StateTag;
            stateLabel.font=[UIFont systemFontOfSize:17.0];
            [cell.contentView addSubview:stateLabel];
        }  

        UILabel* capitalLabel = (UILabel *) [cell.contentView viewWithTag:CapitalTag];
        UILabel*  stateLabel = (UILabel *) [cell.contentView viewWithTag:StateTag];

        capitalLabel.text=[news2 objectAtIndex:indexPath.row];
        stateLabel.text = [news3 objectAtIndex:indexPath.row];

       capitalLabel.backgroundColor = [UIColor clearColor];
        stateLabel.backgroundColor = [UIColor clearColor];

        capitalLabel.textColor=[UIColor whiteColor];
        stateLabel.textColor=[UIColor whiteColor];

        if(count<[news3 count]){
             capitalLabel.numberOfLines = 0;
            [capitalLabel sizeToFit];

            stateLabel.numberOfLines = 0;
            [stateLabel sizeToFit];

        }count++;

        return cell;
    }
 }

我的法典应当作些什么改动?

最佳回答

You should override

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
 // Return YES for supported orientations.
 return (interfaceOrientation == UIInterfaceOrientationPortrait);
 }

通过检查目前方向是否是地貌或漏洞,你可以据此确定标签框架。

问题回答

ry views code code code code code code views views

在<代码>if(m=nil)后添加:

capitalLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;

stateLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;

在SOS公司中,如果改变方向,就会增加任何控制的宽度。 UIViewAutoresizingFlexibleWidth. 这意味着,你的控制范围将根据超级调查框架的规模变化。

Try to SetautoResizingMask, so that view will auto reform change.

您可更改<代码>Xcode尺寸检查员的数值。

“enterography





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签