MAC OSX Mavericks ã®rvmã§ãããã¯ã¾ãã
ããã°ãªãã¦ï¼å¹´ã¶ãã ããã
Â
MAC OSX ã®Â  Mavericks 㧠ruby 1.9.3 ã rvm ä¸ã§ä½¿ããã¨ãããã¯ã¾ã£ãã®ã§ã¡ã¢ã
Â
ãµã¤ãã«ãã£ã¦ruby 1.9.3ã®ã¤ã³ã¹ãã¼ã«ã¨ãã¾ã§ã¯ã§ããã®ã ãã©ã
ãã¤ãã£ããã«ãã®å¿ è¦ãª mysql2 gem ãå ¥ãããã¨ãããããã¦ãã¾ãã
$ gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions with: '--with-mysql-config=/usr/local/mysql/bin/mysql_config'
This could take a while...
ERROR:Error installing mysql2:
ERROR: Failed to build gem native extension.
Â
/Users/nyaago/.rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb --with-mysql-config=/usr/local/mysql/bin/mysql_config
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing.please check your installation of mysql and try again.
-----
*** extconf.rb failed ***
ããã§ãçµéãåºåããã¦ãã mkmf.log ã¨ãããã¡ã¤ã«ãã¿ãã¨ã
"/usr/local/Cellar/gcc46/4.6.4/bin/gcc-4.6 -E -I/Users/nyaago/.rvm/rubies/ruby-1.9.3-p429/include/ruby-1.9.1/x86_64-darwin13.0.0 -I/Users/nyaago/.rvm/rubies/ruby-1.9.3-p429/include/ruby-1.9.1/ruby/backward -I/Users/nyaago/.rvm/rubies/ruby-1.9.3-p429/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -I/usr/local/mysql/include -g -Os -arch x86_64 -fno-common  -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fno-common -pipe conftest.c -o conftest.i"
Â
 x86_64ãããªãã¨ãããããã¦ãããã³ã³ãã¤ã©ããã '-arch x86_64 ' ã¨ããã®ãç解ãã¦ããªãã¨ãããã¨ã®ããã§ããã
ãªãããruby 1.9.3ããã¤ã³ã¹ãã¼ã«ãããã¨ããã¨ããã§ãgcc46 ã¨ããã®ãå¿ è¦ã¨ãããã¨ã§Homebrewã§ãããã¤ã³ã¹ãã¼ã«ãã¦ä½¿ã£ã¦ãããããªãã ãã©ããã®ãgcc46 㯠'-arch 'ã¨ããæå®ãåãä»ããªãã¨ãããã¨ã®ããã
ã¨ãããã¨ã§ãOSã®æ¨æºã³ã³ãã¤ã©ã使ç¨ãããããã«ãã¦ã¿ããã¨ãããã¨ã«ãªãã
OSæ¨æºã®ããã³ãã³ã³ãã¤ã©(clang ï¼ã使ã£ã¦ruby 1.9.3ããªã¤ã³ã¹ãã¼ã«ãã¦ãã mysql2 ã® gem ãã¤ã³ã¹ãã¼ã«ãã¦ã¿ãã
$ rvm reinstall 1.9.3 --with-gcc=clang
Â
......................
Â
$ rvm 1.9.3
Â
$rvm 1.9.3
nyaago@mumichan: 541 $gem install mysql2
Building native extensions. This could take a while...
Successfully installed mysql2-0.3.13
Installing ri documentation for mysql2-0.3.13
Â
1 gem installed
ããã§ãå¤åOKããªãã¾ã åä½ã¯ããã¦ãªããã©ã
CRUDã®Routing è¨å®ã¨Helperã¡ã½ãã
ããããã¨ã²ã£ããã¦ãã¾ãã®ã§ã
Rails3 ã®CRUDã®Routing è¨å®ã¨ããã®è¨å®ã«ãã£ã¦çæãããHelperã¡ã½ããã®é¢é£ã«ã¤ãã¦æ´çãã¦ã¿ã¾ããã
sites ã¨ãã ã³ã³ããã¼ã©ã¼ãä¾ã«ãã¦ãã¾ãã
Routingã®å®ç¾©
routes.rb 㧠(ActionDispatch::Routing::Mapper::Resources ã®) resources ã¡ã½ããã«ãã£ã¦ãURLã¨ãããå¦çããã³ã³ããã¼ã©ã¼ãã¢ã¯ã·ã§ã³ã®å¯¾å¿ã¥ããçæããã¾ãã
Hoge::Application.routes.draw do resources :sites .. end
ãã®è¨å®å¾ãrake routes ãå®è¡ããã¨ã以ä¸ã®ããã«ãURLåã³HTTPã¡ã½ãã(GET/POST/PUT/DELETE)ã¨ããããå¦çããã³ã³ããã¼ã©ã¼/ã¢ã¯ã·ã§ã³ã®Routingè¨å®ãã§ãã¦ãããã¨ã確èªã§ãã¾ãã
$cd <application path> $rake routes sites GET /sites(.:format) {:action=>"index", :controller=>"sites"} POST /sites(.:format) {:action=>"create", :controller=>"sites"} new_site GET /sites/new(.:format) {:action=>"new", :controller=>"sites"} edit_site GET /sites/:id/edit(.:format) {:action=>"edit", :controller=>"sites"} site GET /sites/:id(.:format) {:action=>"show", :controller=>"sites"} PUT /sites/:id(.:format) {:action=>"update", :controller=>"sites"} DELETE /sites/:id(.:format) {:action=>"destroy", :controller=>"sites"}
createï¼æ°è¦ä½æï¼ã®å ´åã¯ãHTTPã¡ã½ããã'POST', update(å¤æ´ï¼ã®å ´åã¯'PUT'ãdestroyï¼åé¤ï¼ã®å ´åã¯'DELETE'ã¨ãªããããããã³ã°ããã¾ãã
çæãããHelper
ä¸è¨ã®ããã«ã«ã¼ãã£ã³ã°ã®å®ç¾©ãè¡ãã¨ä»¥ä¸ã®ã¡ã½ãããèªåçã«çæããã¾ãã
site_path(site, options)
/sites/
new_sites_path(options)
/sites/
edit_site_path(site,options)
/sites/edit/
sites_path(options)
/sites ã¨ããURLãã¹ãè¿ããoptionsã«ã¯ãããã·ã¥ã§ãªã¯ã¨ã¹ããã©ã¡ã¼ã¿ã¼ã§ããããã¼ã¨å¤ãæå®ã
viewã§ã®ãªã³ã¯åºåã§ã®Helperã®ä½¿ãæ¹
edit ã destroy ã®ãªã³ã¯ãä½ãå ´åã®ä¾ã¯ã以ä¸ã®ããã«ãªãã¾ãã
editãªã³ã¯ã®å ´å
link_to 'edit' ,edit_site_path(site, :page => 1) => <a href="/sites/4/edit?page=1">edit</a>
destroyãªã³ã¯ã®å ´åã/sites/ ã®ãã¹ããHttpã¡ã½ããã'DELETE'ã«ãã¦ã®ãªã¯ã¨ã¹ãã«ãªãã¾ãã
link_to 'destroy', site_path(site, :page => 1), :confirm => 'Are you sure?', :method => :delete => <a href="/sites/1?page=1" data-confirm="Are you sure?" data-method="delete" rel="nofollow">destroy</a>
indexã®ä¸è¦§ãã¼ã¸ã
link_to 'index', sites_path => <a href="/sites">index</a>
form ã§ã®ã¤ããããã
form_forãHelper ã¡ã½ããã§ã以ä¸ã®ããã«ãã¢ãã«ã¬ã³ã¼ããå¼æ°ã«æå®ãã¦ããã¨ãupdate ã¾ãã¯ãcreate ã®ããã® form ãåºåããã¾ãã
<%= form_for(@site) do |f| %> .. <% end %>
update ãçæãããå ´å
edit action 㧠form_forã使ãããå ´åãsite_path ã¡ã½ãããå
é¨çã«å¼ã³åºããã¦ãupdateã®ããã®formãåºåããã¾ãã以ä¸ã®ããã«ãurlã/sites/
<form accept-charset="UTF-8" action="/sites/1" class="edit_site" id="edit_site_1" method="post">
create ãçæãããå ´å
new action 㧠form_forã使ãããå ´åãsites_path ã¡ã½ãããå é¨çã«å¼ã³åºããã¦ãcreateã®ããã®formãåºåããã¾ãã以ä¸ã®ããã«ãurlã/sites 㧠Httpã¡ã½ããã'POST'ã¨ãªãformã¨ãªãã¾ãã
<form accept-charset="UTF-8" action="/sites" class="new_site" id="new_site" method="post"
ã¨ããããã以ä¸ãæ¨æºçãåç´ãªå ´åã®ä½¿ãããã«ã¤ãã¦ã
ãã¨ãURLãã¿ã¼ã³ãªã©ããéãå ´åï¼CRUDã§ãªãå ´åãã¬ã³ã¼ãã®id以å¤ãurlã®ãã¿ã¼ã³ã«å«ãå ´åãªã©ï¼ã«ããã¾ãLinkãFormãã¤ãããããããããããããªãã¨..
OpenGL ESã§ã®ç»è§ã®æå®
iPhone ä¸ã§Open GL ES1ãå©ç¨ãã¦ãç»è§ãæå®ãã¦ã®ãªãã¸ã§ã¯ãã®æç»æ¹æ³ã調ã¹ã¦ã¿ã¾ãã®ã§ã
ã¡ã¢ã§ãã
ï¼ãã£ã¨ããã¡ãã¨ããæ¹æ³ãä»ã«ããã®ã ã¨ãã¨ã¯ãããã¾ãã....ï¼
åææºå
- XCodeã§Open GL ES Applicationãé¸æãã¦ããã¸ã§ã¯ããä½æãããã«ãã£ã¦ããã³ãã¬ã¼ãã½ã¼ã¹ãçæãããã
- OpenGL ES 2.0 対å¿ãç¡å¹ã«ãã
EAGLView.m ã® initWithCoder ã¡ã½ããã§ã®ES2Rendererãªãã¸ã§ã¯ãã®çæé¨åãã³ãããããã ã.
// renderer = [[ES2Renderer alloc] init];
ããã§ãES1Renderer.m ã® renderã¡ã½ãããç·¨éãããã¨ã«ããã
Open GL ES1 ã§ã®æç»ããããã¨ãã§ããã
ãããã¯こちらãªã©ãåç §.
æç»å®è£ ã®åæ
ã¨ãããããç°¡ç¥å¯ããããã«ä»¥ä¸ã®å¶éãåæã§ã®å®è£ ã¨ãã¾ããã
- å¹ ->1.0, é«ã->1.0 / (Window ã®å¹ / é«ã), 奥è¡ã1.0ã®ãµã¤ãºã®ãªãã¸ã§ã¯ã空éã«æç»ãããã¨ã¨ããã座æ¨ã¨ãã¦ã¯ãx -> -0.5ã 0.5, y -> -0.5 * (Window ã®å¹ / é«ã)ã0.5 * (Window ã®å¹ / é«ã), z -> -0.5 ã0.5ã®
ç¯å²ã®ãªãã¸ã§ã¯ããæç»ããããã®ã¨ããã
- æ°´å¹³ç»è§ã§ã®è¨ç®ã¨ããã
å®è£
ç»è§/2ã«å¯¾ããtanã®é(ä½æ¥)ã«Object座æ¨ã®å¤§ãã(1.0)ãæãããã®ãã表示ç¯å²ï¼è¦ä½ç©ï¼ã®ä¸çªæåã¨ãªãã
ãã¤ããªãã¸ã§ã¯ãã®æåã«ãªãããã«å®è£
ãã¾ããã
æé ã¨ãã¦ã¯ã
- ç»è§/2ã«å¯¾ããtangentã®é(ä½æ¥)ã«Object座æ¨ã®å¤§ãã(1.0)ãæãããã®ãã表示ç¯å²ï¼è¦ä½ç©ï¼ã®ä¸çªæåã¨ãªããããglFrustumfã§ã®è¨å®ãè¡ãã
- æç»ãªãã¸ã§ã¯ããåç¹ãã表示ç¯å²ã®æåã¾ã§ã®è·é¢ã¨Object座æ¨ä¸ã®Z座æ¨ã®ãã¤ãã¹æ¹åã®å¤§ãããå ããè·é¢ã ããã¤ãã¹æ¹åã«ç§»å.ããã§ãObjectã®ãã¤ãã¹å´ã®ä¸çªæåãã表示ç¯å²ï¼è¦ä½ç©ï¼ã®ä¸çªæåã¨ãªã.
ES1Renderer.m ã® renderã¡ã½ããã®å®è£
ã¯ä»¥ä¸ã®ã¨ããã§ããç»è§ã¯60度ã¨ãã¿ã«æå®ãã¦ãã¾ãã
- (void)render { // This application only creates a single context which is already set current at this point. // This call is redundant, but needed if dealing with multiple contexts. [EAGLContext setCurrentContext:context]; // This application only creates a single default framebuffer which is already bound at this point. // This call is redundant, but needed if dealing with multiple framebuffers. glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer); glViewport(0, 0, backingWidth, backingHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); GLfloat fovy = 60.0f; // ç»è§ã60度ã¨ãã /* è§åº¦ã«ããããè¦ä½ç©ã®è¨å®. tanã®é(ä½æ¥)ã«Object座æ¨ã®å¤§ãããæãããã®ãã nearã®ä½ç½®ã«ããããã«ãã. */ GLfloat aspect = (GLfloat)backingWidth / (GLfloat)backingHeight; GLfloat width = 1.0f; GLfloat height = width / aspect; GLfloat near = 1.0f; GLfloat far = 100.0f; near = 1.0f / tan(fovy * 0.5 * M_PI / 180.0) * width; GLfloat x = width / 2; GLfloat y = height / 2; glFrustumf(-x, x, -y, y, near, far); NSLog(@"glFrustumf(%f,%f,%f,%f,%f,%f)",-x, x, -y, y, near, far); /* è¦ä½ç©ã®nearã®ä½ç½®ã«ãããã¦ãã¢ãã«Z座æ¨ã移å åç¹ããnearã¾ã§ã®è·é¢ï¼Objectã®Z座æ¨ã®ãã¤ãã¹æ¹åã¸ã®å¤§ããåã ããã¤ãã¹æ¹åã«ç§»å. ããã§ãObjectã®ãã¤ãã¹å´ã®ä¸çªæåãã è¦ä½ç©ã®ä¸çªæåã¨ãªã. */ // glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0f, 0.0f, -(width / 2) - near); NSLog(@"glTranslatef z = %f",-(width / 2) - near); // .... ããã§ãªãã¸ã§ã¯ãã®æç»ã.... // [self draw]; // // This call is redundant, but needed if dealing with multiple renderbuffers. glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer); [context presentRenderbuffer:GL_RENDERBUFFER_OES]; }
scrollViewå ã«ImageViewãé ç½®ããã
iPhoneã¢ããªã§ãscrollViewå ã«ä»»æã®ç¸¦æ¨ªæ¯ã®ImageViewãã»ã³ã¿ãªã³ã°ãã¦é ç½®ããããã®å®è£ ãè¡ã£ã¦ã¿ãã
scrollviewã®çæ
åæã¨ãªãæºåã¨ã㦠view loadæã«scrollViewã®çæ,ã»ããã¢ãããè¡ãã
- (void)viewDidLoad { NSLog(@"photo view contoller viewDidLoad"); [super viewDidLoad]; .... ãããã .... CGRect rect = self.view.bounds; scrollView = [[UIScrollView alloc] initWithFrame:rect]; scrollView.maximumZoomScale = 3.0; scrollView.minimumZoomScale = 1.0; scrollView.delegate = self; scrollView.scrollEnabled = YES; scrollView.userInteractionEnabled = YES; scrollView.bounces = NO; scrollView.multipleTouchEnabled = YES; [self.view addSubview:scrollView]; }
ImageViewã追å
ImageViewã追å ãã(Viewã表示ãããã¿ã¤ãã³ã°ãªã©)ããã«ã¯ã以ä¸ã®ããã«ã»ã³ã¿ãªã³ã°ãããããview frameã®éå§åº§æ¨ãè¨å®ããã°ããã
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; .... ãããã ..... CGSize size = self.imageView.image.size; CGRect viewRect = self.scrollView.bounds; CGRect rect; if(size.height / size.width > viewRect.size.height / viewRect.size.width ) { // ç¸¦é· float rate = viewRect.size.height / image.size.height; float width = size.width * rate; rect = CGRectMake((viewRect.size.width - width) / 2, 0.0f, width, viewRect.size.height); } else { // æ¨ªé· float rate = viewRect.size.width / image.size.width; float height = size.height * rate; rect = CGRectMake(0.0f, (viewRect.size.height - height) / 2, viewRect.size.width, height); } imageView.frame = rect; }
Zoomingæã®åº§æ¨èª¿æ´
Zoomingæã«ãã»ã³ã¿ãªã³ã°ãããããview frameã®éå§åº§æ¨ã調æ´ãã¦ããå¿
è¦ãããã
scrollViewã®Delegate(UIScrollViewDelegateãããã³ã«)ã®- (void)scrollViewDidZoom:(UIScrollView *)scrollView
ã¡ã½ããã§è¡ãã
- (void)scrollViewDidZoom:(UIScrollView *)scrollView { CGRect frame = imageView.frame; if( (self.scrollView.bounds.size.width - self.scrollView.contentSize.width) / 2 > 0) { frame.origin.x = (self.scrollView.bounds.size.width - self.scrollView.contentSize.width) / 2; } else { frame.origin.x = 0.0f; } if((self.scrollView.bounds.size.height - self.scrollView.contentSize.height) / 2 > 0) { frame.origin.y = (self.scrollView.bounds.size.height - self.scrollView.contentSize.height) / 2; } else { frame.origin.y = 0.0f; } imageView.frame = frame; }
Zooming/ScrollãããViewã®æå®ãå¿ããã«
ãã¡ãããDelegate(UIScrollViewDelegateãããã³ã«)ã®- viewForZoomingInScrollView:ã¡ã½ããã§ScrollViewå ã«å«ããimageViewã®æå®ãè¡ã£ã¦ããå¿ è¦ãããã
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return self.imageView; }
æç¶ãã®æ½è±¡å
sicp ã®1.3.3 ã¨1.3.4ãã復ç¿ãgeneral Methodã¨æç¶ããè¿ãæç¶ããã¤ãã£ã¦ã®æç¶ãã®æ½è±¡åãé¡æã¯ä¸»ã«ãå¹³æ¹æ ¹ã§ã
[1.3.3 general Methodã使ã£ã¦ã®æ½è±¡å]
æå®ããæç¶ãã®å ¥åã¨åºåã®å·®ãååå°ãããªããªãæç¹(fixed point)ã®å ¥åå¤ãå¾ãããã®æç¶ã fixed-pointãå®ç¾©ã
(define tolerance 0.00001) (define (fixed-point f first-guess) (define (close-enough? x y) (< (abs (- x y) ) tolerance) ) (define (try guess) (let ((next (f guess) ) ) (if (close-enough? next guess) next (try next) ) ) ) (try first-guess) )
ãã®æç¶ãã使ã£ã¦ãå¹³æ¹æ ¹ãè¿ãæç¶ããå®ç¾©ã
ç®åºå¤ã®åæå¤ 1.0ã¨ãã¦
((å¹³æ¹æ ¹ç®åºå¯¾è±¡ã®å¤/ååã®ç®åºå¤) ã¨ååç®åºå¤ã®å¹³åå¤)ã®ç®åºãç¹°ãè¿ãå®è¡ã fixed point(ååã¨ä»åã®ç®åºå¤ã®å·®ãååå°ãããªãæç¹)ã®ç®åºå¤ãå¹³æ¹æ ¹ã®çµæã¨ããã
(define (sqrt x) (fixed-point (lambda (y) (average y (/ x y) ) ) 1.0) )
[1.3.4 æç¶ããè¿ãæç¶ã]
æç¶ããè¿ãæç¶ããå®è£
ãããã¨ã«ãããæ½è±¡åãè¡ãã
æå®ããæç¶ãã®å
¥åã¨åºåã®å¹³åãæ±ããæç¶ããè¿ãæç¶ã
ãã®æç¶ããæç¶ãã®å·®ãååå°ãããªãã¨ãã®åºåå¤ãæ±ããæç¶ã(fixed-point)ã«ãããã¦å¹³æ¹æ ¹ãã¨ã
ããã§ã¯ã以ä¸ã®ï¼ã¤ã®æç¶ããçµã¿åããã¦ãããã¨ã«ãªãã
-
-
- x/yãæ±ããlambda
- æå®ããæç¶ãã®å ¥åã¨åºåã®å¹³åãæ±ããæç¶ããè¿ãæç¶ã(average-dump)
- æç¶ãã®å ¥åã¨çµæã®å·®ãååå°ãããªãã¨ãã®åºåå¤ãæ±ããæç¶ã(fixed-point)
-
(define (average-dump f) (lambda (x) (average x (f x)))) (define (sqrt x) (fixed-point (average-dump (lambda (y) (/ x y) ) ) 1.0) )
ããã«
ããã«ãä¸è¨ã®2ã®ç®ã®æç¶ã(average-dump)ãã1ã¤ãã®æç¶ãï¼x/yãæ±ããlambda)ãå¼ã³åºãã®ã§ã¯ãªããããããã®æç¶ãå¼æ°ã§æ¸¡ãããã«æ½è±¡åããã¨ã
(define (fixed-point-of-transform g transform guess) (fixed-point (transform g) guess) ) (define (sqrt x) (fixed-point-of-transform (lambda (y) (/ x y) ) average-dump
addSubViewã§è¿½å ãããã¿ã¤ãã³ã°ã§sub Viewã表示
課é¡
iphoneã§Viewã表示ãããã¨ãã«ä¸ä½ã«ViewãControlã追å ããã¨ãã®ãã¨ã§ããviewDidAppear:ã§addSubViewã使ã£ã¦ViewãControlã追å ããã¨ãviewDidAppearã®å¦çãå®äºãã¦ãããUiKitã«ãã£ã¦ä¸æ¬ãã¦æç»ãè¡ããããã¨ã«ãªãã¾ããããããã¨ä¸ä½ã®è¦ç´ æ°ãå¤ãå ´åãªã©ã¯ãæç»ãå§ããã¾ã§æéãããã£ã¦ãã¾ããã¨ã«ãªãããã®ãããæå¾ã«ä¸æ¬ãã¦ãæç»ãããã®ã§ã¯ãªãaddSubViewã§Viewé層ã«è¿½å ããããã³ã«è¡¨ç¤ºãããå ´åãããã¾ãã
解決æ¹æ³
ã¾ããä¸ä½ã®View,Controlã追å ããããã®å¦çã¯ãUIKitã®æç»å¦çã¨éåæã«è¡ãããããã«viewDidAppear:ããæ°è¦ã¹ã¬ããã§èµ·åãããããã«ãã¾ããå
·ä½çã«ã¯NSThreadã使ããã¨ã«ãªãã¾ãã
ãã®å¥ã¹ã¬ããã§ãä¸ä½ã®View,Controlã追å ãã¦ããã®ã ãããã®å¥èµ·åããã¦ããã¹ã¬ããã§addSubViewãã¦ãããã¡ãããæç»ã®å¦çã¯èµ·åãããªããããã§ãæç»ãè¡ãã¹ã¬ãããã¤ã¾ãã¡ã¤ã³ã¹ã¬ããã§addSubViewãè¡ãå¿
è¦ãããã¾ããããã§ãåã
ã®addSubViewãè¡ãå¥ã¡ã½ãããä½æãNSObjectã®performSelectorOnMainThread:withObject:waitUntilDoneã¡ã½ããã使ã£ã¦ããããã¡ã¤ã³ã¹ã¬ããã§èµ·åãããããã«ãã¾ãã
ããã§ãå ·ä½çã®ã©ã®ãããªå®è£ ã«ãªããã以ä¸ã§ãã
viewDidAppear:ã§ã¯ã以ä¸ã®ã¨ãããNSThreadã® detachNewThreadSelector:toTaarget:withObjectãªã©ã«ãããview追å ã®ã¡ã½ãããå¥ã¹ã¬ããã§å¼ã³åºãã¾ãã
- (void) viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [NSThread detachNewThreadSelector:@selector(afterViewDidAppear:) toTarget:self withObject:nil]; }
å¥ã¹ã¬ããã§èµ·åããããã¡ã½ããå
ã§ã¯ãviewããã®viewããã¡ã¤ã³ã¹ã¬ããã§è¿½å ãããããã«ãNSObjectã®performSelectorOnMainThread:withObject:waitUntilDoneã¡ã½ããã«ãããå®éã®view追å ãè¡ãã¡ã½ãããå¼ã³åºãã¾ãã
- (void) afterViewDidAppear:(id)arg { for(NSUInteger i = 0; i < [self subViewCount]; ++i) { UIView *subView = [self subViewAt:i]; if(imageView) { [self performSelectorOnMainThread:@selector(addView:) withObject:subView waitUntilDone:NO]; } }
å®éã«view,controlã®è¿½å ãè¡ãã¡ã½ããã¯ãåç´ãªå ´åã¯ã以ä¸ã®ããã«åã«addSubViewãå¼ã³åºãã ãã¨ãªãã¾ãã
- (void)addView:(id)subView { [self.view addSubview:subView]; }
Barã®è¡¨ç¤º/é表示åãæ¿ã(navigationView-scrollViewæ§æ)
navigationView ã®ä¸ã«scrollViewãããã¨ããæ§æã®å ´åã«
iphone - navigationBar,statusBar,toolBarã®On/Offããããããã«ããã表示ãOnã®å ´åã«ããå
¨ç»é¢è¡¨ç¤ºã§navigationBar,statusBar,toolBarãåéæã§ããç¶æ
ã«ãããã¨ããå®è£
ããããããªãã¿ãªããå®è£
ãã¦ã¿ã¾ããã
åæ表示
ã¾ã,Viewã表示ãããåã«(=UIViewControllerã®viewWillAppear)ã§ã¯ãå ¨ç»é¢è¡¨ç¤ºããããã¨(UIViewControllerã®wantsFullScreenLayout)ã®è¨å®ãè¡ãã¾ã
- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; // å ¨ç»é¢è¡¨ç¤º self.wantsFullScreenLayout = YES; }
(ä»¥ä¸ 5/19追è¨)
ã¤ãã®,Viewã表示ãããã¨ã(=UIViewControllerã®viewDidAppear)ã«ã¯ãåBarã«å¯¾ãã¦ä»¥ä¸ã®è¨å®ãè¡ãããããã表示ãããªãããã«ãã¾ããã
-
-
- Barã®åéæã®ã¹ã¿ã¤ã«è¨å®
- Barãé表示ã«ããè¨å®
å ¨ç»é¢è¡¨ç¤ºããããã¨(UIViewControllerã®wantsFullScreenLayout)
-
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; self.navigationController.toolbarHidden = YES; .... ScrollViewå ã«View/UIControlã®é ç½®ãããå¦ç .... // Navigation Bar, Status Bar, ToolBarã®ã¹ã¿ã¤ã«(éæãé»ï¼ self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent; [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent; self.navigationController.toolbar.barStyle = UIBarStyleBlack; self.navigationController.toolbar.translucent = YES; // Navigation Bar, Status Bar, ToolBarãé表示㫠[UIApplication sharedApplication].statusBarHidden = YES; self.navigationController.navigationBar.hidden = YES; self.navigationController.toolbarHidden = YES; .... }
表示/é表示ã®åãæ¿ã
表示/é表示ã®åãæ¿ãã«ã¯ãä¸è¨ã¨åæ§ã«å表示è¨å®ã®ããããã£å¤ãæå®ãããã¨ã«ããè¡ããã¯ããã¨ãããã¨ã§ã
// 表示/é表示ã®å転 BOOL hidden = !self.navigationController.navigationBar.hidden; self.navigationController.navigationBar.hidden = hidden; [[UIApplication sharedApplication] setStatusBarHidden:hidden animated:YES]; [self.navigationController setToolbarHidden:hidden];
表示ä½ç½®ã«ããã¸ã®å¯¾å¿
以ä¸ã®ããã«ãã¦ã表示ã®åãæ¿ãã¯ã§ããã®ã ããã©ãnavigationBarã®åãªã®ãtoolBarã®åãªã®ãããããªãããä¸æ¹åã«è¡¨ç¤ºåº§æ¨ãããã¦ãã¾ãã調ã¹ã¦ã¿ãã¨æç»å¾ã«ScrollViewã®å 容ãé ç½®ããããã®Insetã¨Offset(contentInsetã¨contentOffsetããããã£ï¼ãããã¦ãã¾ãã¾ãããã®ããä¸æ¦UIKitã®æç»ããããå¾ã«ããããã®ããããã£ãåæç¶æ (offsetã¯x,yã¨ã0,Insetãå ¨ã¦0ã«ï¼ã«æ»ãããã«ãã¾ãããã®åæç¶æ ãæ»ãå¦çãã¡ã½ããã¨ãã¦å®ç¾©ãã¦ãNSObjectã§å®ç¾©ããã¦ãã[performSelectorOnMainThread:withObject:waitUntilDone]ã§ãããå¼ã³åºããã¨ã«ãã£ã¦è¡ãã¾ãã
- (void)resetScrollOffsetAndInset:(id)arg { PageScrollView *scrollView = (PageScrollView *)self.view; UIEdgeInsets inset; inset.left = 0; inset.right = 0; inset.top = 0; inset.bottom = 0; scrollView.contentInset = inset; CGSize size = scrollView.contentSize; size.height = self.view.frame.size.height; scrollView.contentSize = size; } // 表示/é表示ã®å転 -(void) changeNavigationAndStatusBar { BOOL hidden = !self.navigationController.navigationBar.hidden; self.navigationController.navigationBar.hidden = hidden; [[UIApplication sharedApplication] setStatusBarHidden:hidden animated:YES]; [self.navigationController setToolbarHidden:hidden]; // scrollViewã®contentã®offsetã¨insetãå ã®ç¶æ ã«æ»ã [self performSelectorOnMainThread:@selector(resetScrollOffsetAndInset:) withObject:[NSNumber numberWithBool:hidden] waitUntilDone:NO]; }
æ©å¨å転æãªã©
æ©å¨å転æã®å¯¾å¿ãããå ´åãªã©ã表示/é表示ã®å転ã¨åæ§ã«ScrollViewã®ContentInsetã¨contentOffsetãå ã«æ»ãããã«[performSelectorOnMainThread:withObject:waitUntilDone]ã®å¼ã³åºããå¿ è¦ã§ããã
ã¾ã ã¾ã 課é¡
åæç¶æ
ã§Barã表示ããã¨ãä½ç½®ãããã¦ãã¾ããªã©ãã¾ã åé¡ããã§ãã