※ iphone開発初心者です。私はuitextviewに1つの問題があります...私がやろうとしているのは、uitextviewで選択した文字列をテキストビューの外からドラッグすることです...そしてそれをtabbarcontrollerにドラッグすることは可能ですか? *これは私が今までに返したコードです....助けてください
#
import <UIKit/UIKit.h>
#import "TabViewController.h"
@class TabBarViewController;
@interface TabBarAppDelegate : UIResponder <UIApplicationDelegate,UITabBarControllerDelegate>
{
TabBarViewController *txtviewcontroller;
UITabBarController *tabbar;
NSArray *viewcontrollerarray;
}
@property(nonatomic,retain)NSArray *viewcontrollerarray;
@property(nonatomic,strong)UITabBarController *tabbar;
@property(nonatomic,retain)TabBarViewController *txtviewcontroller;
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) TabBarViewController *viewController;
@end
#import "TabBarAppDelegate.h"
#import "TabViewController.h"
@implementation TabBarAppDelegate
@synthesize txtviewcontroller,tabbar,viewcontrollerarray;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor=[UIColor whiteColor];
self.tabbar=[[UITabBarController alloc]init];
txtviewcontroller=[[TabBarViewController alloc]init];
tabbar.delegate=self;
viewcontrollerarray=[[NSArray alloc]initWithObjects:txtviewcontroller, nil];
self.tabbar.viewControllers=viewcontrollerarray;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[TabBarViewController alloc] initWithNibName:@"TabBarViewController_iPhone" bundle:nil];
} else {
self.viewController = [[TabBarViewController alloc] initWithNibName:@"TabBarViewController_iPad" bundle:nil];
}
self.window.rootViewController = self.tabbar;
[self.window makeKeyAndVisible];
return YES;
}
#import <UIKit/UIKit.h>
@interface TabBarViewController : UIViewController
{
UITextView *textview;
}
@property(nonatomic,retain)UITextView *textview;
@end
#import "TabViewController.h"
#import "TabBarAppDelegate.h"
#include <QuartzCore/CoreAnimation.h>
@interface TabBarViewController ()
@end
@implementation TabBarViewController
@synthesize textview;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.title=@"firstname";
CGRect textViewFrame = CGRectMake(20.0f, 20.0f, 280.0f, 124.0f);
textview = [[UITextView alloc] initWithFrame:textViewFrame];
textview.backgroundColor=[UIColor clearColor];
textview.textColor=[UIColor blackColor];
textview.editable=NO;
NSString *filePath=[[NSBundle mainBundle]pathForResource:@"satyadetails" ofType:@"txt"];
NSString *contentString=[NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
textview.text=contentString;
textview.layer.borderWidth = 3.0f;
textview.layer.borderColor = [[UIColor grayColor] CGColor];
textview.returnKeyType = UIReturnKeyDone;
[self.view addSubview:textview];
enter code here
}