媒介
不曉得年夜家有無碰到過在做輪播圖的時刻,有點輪播圖展現的是告白,有的是運動,等等還有其他的,以後點擊某個輪播的時刻要跳轉到分歧的掌握器,點擊事宜是在掌握器寫的,為了不掌握器代碼過量,顯示的癡肥。我創立了一個UIWindow的分類,暫且叫Model (GetCurrentVC)
完成辦法
谷歌還有許多辦法,上面這個辦法親測有用,有須要的可以參考自創。
一:
@interfaceUIWindow (GetCurrentVC) - (UIViewController*)getCurrentVC; @end
二:
#import"UIWindow+GetCurrentVC.h"
@implementationUIWindow (GetCurrentVC)
- (UIViewController*)getCurrentVC {
UIViewController*result =nil;
UIWindow* window = [[UIApplicationsharedApplication]keyWindow];
if(window.windowLevel!=UIWindowLevelNormal)
{
NSArray*windows = [[UIApplicationsharedApplication]windows];
for(UIWindow* tmpWininwindows)
{
if(tmpWin.windowLevel==UIWindowLevelNormal)
{
window = tmpWin;
break;
}
}
}
UIView*frontView = [[windowsubviews]objectAtIndex:0];
idnextResponder = [frontViewnextResponder];
if([nextResponderisKindOfClass:[UIViewControllerclass]])
result = nextResponder;
else
result = window.rootViewController;
returnresult;
}
@end
總結
以上就是IOS若何獲得以後View地點掌握器的完成辦法,願望本文對年夜家開辟IOS能有必定的贊助,若有有疑問年夜家可以留言交換。
【iOS完成只要底部邊框線的輸出框示例代碼】的相關資料介紹到這裡,希望對您有所幫助! 提示:不會對讀者因本文所帶來的任何損失負責。如果您支持就請把本站添加至收藏夾哦!