【问题标题】:IPhone: create view with text and imagesiPhone:使用文本和图像创建视图
【发布时间】:2023-03-18 00:57:02
【问题描述】:

我想创建一些视图,并动态添加文本和图像 有人知道我该怎么做吗?

谢谢

【问题讨论】:

    标签: iphone image text


    【解决方案1】:

    广泛的问题,但这应该让你走上正确的道路:(将其放入视图控制器中)

    -(void)addStuffToView{
        UIView* myView = [self view]; // get the view controller's view
    
        UIImageView* myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,100,100)];
        [myImageView setImage:[UIImage imageNamed:@"imagefile.jpg"]];
        [myView addSubview:myImageView];
        [myImageView release];
    
        UILabel* myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,100,100,50)];
        myLabel.text = @"Some text here";
        [myView addSubview:myLabel];
        [myLabel release];
    }
    

    然后,使用 Interface Builder 将此方法绑定到 UIButton 的 touchUpInside 事件。

    【讨论】:

    • 谢谢,但我想在某些事件中添加它,例如在按钮单击时
    • 习惯上赞成或接受解决您的问题或以某种方式提供帮助的答案。
    • 真的吗?有趣的。而且我想“接受”再过十分钟就无法使用了。好吧,试试代码,让我知道它是如何为你工作的。您还应该考虑使用导航视图。
    • 好吧,你觉得 UIWebView 怎么样,也许它会更好?
    猜你喜欢
    • 2011-10-27
    • 2023-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多