这是我的代码:
BlowVIEw.h
#import <UIKit/UIKit.h>@interface BlowVIEw : UIVIEw { UIImageVIEw *stone;}@property (nonatomic,retain) UIImageVIEw *stone;- (ID)init;@end
BlowVIEw.m
#import "BlowVIEw.h"@implementation BlowVIEw@synthesize stone;- (ID)init { UIImageVIEw *logoVIEw = [[UIImageVIEw alloc] initWithImage:[UIImage imagenamed:@"Placard.png"]]; stone = logoVIEw; [logoVIEw release]; UIImage *img = [UIImage imagenamed:@"Placard.png"]; CGRect frame = CGRectMake(0,img.size.wIDth,img.size.height); [self initWithFrame:frame]; return self;}- (ID)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if(self) { } return self;}- (voID)dealloc { [stone release]; [super dealloc];}@end
BlowVIEwController.h
@class BlowVIEw;@interface BlowVIEwController : UIVIEwController { BlowVIEw *avIEw;}@property (nonatomic,retain) BlowVIEw *avIEw;-(voID)setUpVIEw;@end
BlowVIEwController.m
#import "BlowVIEwController.h"#import "BlowVIEw.h"@implementation BlowVIEwController@synthesize avIEw;- (voID)setUpVIEw { // Create the placard vIEw -- its init method calculates its frame based on its image BlowVIEw *aVIEw2 = [[BlowVIEw alloc] init]; self.avIEw = aVIEw2; [aVIEw2 release]; self.vIEw = self.avIEw;}- (voID)dIDReceiveMemoryWarning{ // Releases the vIEw if it doesn't have a supervIEw. [super dIDReceiveMemoryWarning]; // Release any cached data,images,etc that aren't in use.}- (voID)vIEwDIDLoad { [super vIEwDIDLoad]; [self setUpVIEw]; avIEw.center = self.vIEw.center;}- (voID)vIEwDIDUnload{ [super vIEwDIDUnload]; // Release any retained subvIEws of the main vIEw. // e.g. self.myOutlet = nil;}- (BOol)shouldautorotatetoInterfaceOrIEntation:(UIInterfaceOrIEntation)interfaceOrIEntation{ // Return YES for supported orIEntations return (interfaceOrIEntation == UIInterfaceOrIEntationPortrait);}- (voID)dealloc { [avIEw release]; [super dealloc];}@end
无法弄清楚我哪里出错了.我没有错误..我得到的只是一个空白的白色碎片.任何帮助将受到高度赞赏:)
解决方法 在您的第一个代码段中,您尚未将图像添加到视图中,请在下面进行修改:UIImageVIEw *logoVIEw = [[UIImageVIEw alloc] initWithImage:[UIImage imagenamed:@"Placard.png"]];stone = logoVIEw;[logoVIEw release];UIImage *img = [UIImage imagenamed:@"Placard.png"];CGRect frame = CGRectMake(0,img.size.height);[self initWithFrame:frame];// Here add your imageVIEw(stone) to your vIEw as a subvIEw[self addSubvIEw:stone];return self;总结
以上是内存溢出为你收集整理的ios – 将图像添加到UIView全部内容,希望文章能够帮你解决ios – 将图像添加到UIView所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)