Klavyenin üstüne bir araç çubuğu ekledim, kullanıcının bir TextView'ı her tıkladığında görünür, ayrıca TextView ile değiştiren ve etkileşimde bulunan, örneğin metni değiştiren çok sayıda düğme vardır. yazı tipi.Araç çubuğu
Şimdi ne yapmaya çalışıyorum diğer TextView'lar üzerinde kullanılabilir böylece Araç Çubuğu bir alt sınıfını oluşturmak için, ama benim problem:
Nasıl Toolbar içerisinden TextView'un temsilci yöntemleri kullanmak alt sınıf? İşte
(çok büyük yazı yapmıyor için, tüm kodu) benim geçerli kod:.h
#import <UIKit/UIKit.h>
@interface CustomUIToolbar : UIToolbar{
UIButton *btn1;
UIButton *btn2;
UIButton *btn3;
}
.m
@implementation CustomUIToolbar
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
UIBarButtonItem *one = ...
UIBarButtonItem *two = ...
UIBarButtonItem *three = ...
self.barStyle = UIBarStyleDefault;
self.layer.borderWidth = 1;
self.layer.borderColor = [[UIColor lightGrayColor] CGColor];
self.items = [NSArray arrayWithObjects:one,placeholder,two,three,four,five,nil];
[self sizeToFit];
}
return self;
}
-(void)actionBtn3:(UIButton *) barBtnItem{
...
}
-(void)actionBtn2:(UIButton *) barBtnItem{
...
}
-(void)actionBtn1:(UIButton *) barBtnItem{
...
}
// And the UITextView Delegate Methods
- (BOOL) textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
...
return YES;
}
- (void)textViewDidChangeSelection:(UITextView *)textView {
...
}
bu işe yaramıyor – Bruno
Özel tabbar örneğinizi başlattığınız ve temsilci atadığınız kodu gösterebilir misiniz? –
UIToolbar * tool = [[CustomUIToolbar alloc] init]; self.textView.inputAccessoryView = aracı; self.textView.autocorrectionType = UITextAutocorrectionTypeNo; – Bruno