Hi I was wondering if anyone has come across any good tutorials or guides for adding dynamic UIView subclasses to other uiviews and uiscrollviews?
I am working on an app at the moment which requires a couple of uiview subclasses which I then need to be able to generate on the fly and add to a uiview.
For example, I need to generate an anagram view in one area of the application. This will require me to create some drag and drop views, each of which will correspond to a single letter. If anyone has any ideas as to how I can achieve this. I have created a subclass for a single letter, and had hoped to build it using a simple label and a graphic behind the letter which will highlight whether or not it is correct.
I have an IBAction hooked up to a button and it processes this code:
Code:
AnagramLetter *test = [[AnagramLetter alloc] init];
[letterHolder addSubview:test];
I know that this is being processed as I have added a couple of NSLogs to check whether or not the label etc is being processed properly:
Code:
@implementation AnagramLetter
@synthesize testLbl;
- (id)initWithFrame:(CGRect)frame
{
frame = CGRectMake(20, 55, 100, 100);
self = [super initWithFrame:frame];
if (self) {
// Initialization code
NSLog(@"I exist");
testLbl = [[UILabel alloc] init];
[testLbl setText:@"Text should now be set"];
[self addSubview:testLbl];
NSLog(@"this is the label's value: %@",testLbl.text);
}
return self;
}
The logs are being output, however it is not showing up on the application screen, or seemingly is not being added to the letterHolder UIView object properly.
Any ideas?
Conor
Conor