Android에서 많이 사용하는 ViewPager의 예제이다. ViewPager를 사용하려면 필수적으로 FragmentActivity를 사용해야하는데, ActionBarActivity를 사용하고 있으면 무시하고 ActionBarActivity를 그대로 사용해도 된다.(FragmentActivity를 상속받고 있기 때문이다.) public class MainActivity extends ActionBarActivity { private ViewPager mViewPager; private PagerAdapter mPagerAdapter; private class PagerAdapter extends FragmentStatePagerAdapter { public PagerAdapter(FragmentMana..
안드로이드 스튜디오에서 라이브러리 프로젝트를 jar 파일로 만드는 방법을 알아보자. //기존의 jar파일을 지우는 task task deleteOldJar(type: Delete) { delete 'release/daumapi.jar' } //라이브러리 프로젝트의 output인 classes.jar를 daumapi.jar로 이름 변경 task exportJar(type: Copy) { // classes.jar 패스는 여기에 떨어짐 from('build/intermediates/bundles/release/') into('release/') include('classes.jar') rename('classes.jar', 'daumapi.jar') } exportJar.dependsOn(deleteOldJ..
Table 1. Dangerous permissions and permission groups.Permission GroupPermissionsCALENDARREAD_CALENDARWRITE_CALENDARCAMERACAMERACONTACTSREAD_CONTACTSWRITE_CONTACTSGET_ACCOUNTSLOCATIONACCESS_FINE_LOCATIONACCESS_COARSE_LOCATIONMICROPHONERECORD_AUDIOPHONEREAD_PHONE_STATECALL_PHONEREAD_CALL_LOGWRITE_CALL_LOGADD_VOICEMAILUSE_SIPPROCESS_OUTGOING_CALLSSENSORSBODY_SENSORSSMSSEND_SMSRECEIVE_SMSREAD_SMSREC..
@implementation ViewController - (void)viewDidLoad{ [super viewDidLoad];// Do any additional setup after loading the view, typically from a nib. NSFileManager * fileManager = [NSFileManager defaultManager]; NSString *currentPath = [fileManager currentDirectoryPath]; NSArray *dirPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentPath = [dirPa..
UITouch *touch = [touches anyObject]; CGPoint currentPoint = [touch locationInView:drawImage]; UIGraphicsBeginImageContext(drawImage.frame.size); [drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), size); CGContextSetRGBStro..
iOS 프로그램을 개발하다보면 ARC(Auto Reference Counting) 프로젝트에서 non-ARC 소스를 컴파일 해야 할 때가 있다. 그럴때는 다음과 같이 Build Phases에서 해당하는 .m(ObjC) 파일의 옵션에다가 '-fno-objc-arc'를 하게 되면 해당 .m 파일만 non-ARC 방식으로 컴파일할 수 있다. 최신 프로젝트에 구형 SDK를 연동할때 많이 쓰는 방식이다. 나는 이걸 몰라서 C#에 Native C++을 연동할때 Managed C++ 프로젝트를 만드는 것처럼 프로젝트를 ARC/non-ARC 분리를 했는데 그렇게 하면 더 많은 문제가 생긴다. iOS에서는 이 방식을 추천한다.
iOS 프로젝트에서 스토리보드를 제거하는 방법을 알아보자. 스토리보드가 있으면, 대형 프로젝트에서 여러사람이 협업시에 불편한점이 있고 수동으로 뷰를 컨트롤 하는게 명확하므로 제거하는 것이 좋다. 1. main.plist에서 "Main storyboard base file name"을 삭제해준다. 2. 기존 뷰 컨트롤러를 삭제해 준다. 예제에서는 ViewController.h/m이다. 3. 뷰 컨트롤러를 새로 생성한다. 생성하는 방법은 New file - iOS - Source - Cocoa Touch Class이다. 그리고 반드시 XIB를 생성하는 옵션을 선택하여야 한다. 4. AppDelegate.m에 다음과 같은 코드를 추가 한다. - (BOOL)application:(UIApplication *)a..
iOS 최신 버전에서는 [[UIDevice currentDevice]model]을 하여도 "iPhone"이라는 문자열 밖에 얻을 수 없다. 따라서 아래와 같이 구현하면 최신 iOS에서도 디바이스 모델 정보를 얻어올 수 있다. 다만 시뮬레이터에서 실행하면 x86_64가 얻어진다.(64비트 아이폰의 경우) #import // import it in your header or implementation file. NSString* deviceName() { struct utsname systemInfo; uname(&systemInfo); return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; } @"i386" ..
- Total
- Today
- Yesterday