在React Native项目中,我想从iOS npm模块访问Presented Viewcontroller。我可以使用下面的代码
访问RN项目的rootviewcontrollerUIViewController *vc = [UIApplication sharedApplication].delegate.window.rootViewController;
但我想要在RootVC之上呈现的当前VC,以便我能够在其上呈现本机(iOS)UINavigationController。
注意:[UIApplication sharedApplication].delegate.window.rootViewController.presentedViewController
返回nill。
答案 0 :(得分:0)
我知道很久以前就问过这个问题,但是今天我遇到了同样的问题(from bs4 import BeautifulSoup
import requests
import csv
pagenum=15
maxpage = 30
while pagenum <= maxpage:
newsu =pagenum
newsu = str(newsu)
csvname = 'dealers'+newsu+'.csv';
csvfile = open(csvname , 'w')
csv_writer = csv.writer(csvfile)
csv_writer.writerow(['Business name', 'phone' , 'address' , 'website'] )
page = 'https://www.yellowpages.com/search?search_terms=car%20dealer&geo_location_terms=Queens%2C%20NY&page={}'.format(pagenum)
pagenum = pagenum+1
source= requests.get(page).text
x=0;
soup= BeautifulSoup(source, 'lxml')
ParentDiv=soup.find('div' , class_='organic')
for PParentDiv in ParentDiv.find_all('div' , class_='v-card'):
ress=addr=''
PName = PParentDiv.find('a' , class_='business-name').span.text
phone = PParentDiv.find('div' , class_='phones phone primary').text
ress = PParentDiv.find('div' , class_='street-address').get_text()
addr = PParentDiv.find('div' , class_='locality').get_text()
address = ress + ' ' + addr
x=x+1
print(x)
try:
website = PParentDiv.find('a' , class_='track-visit-website').get('href')
except Exception as e:
website=''
csv_writer.writerow([PName, phone , address , website])
csvfile.close()
返回了[UIApplication sharedApplication].delegate.window.rootViewController.presentedViewController
),并且暂时找不到解决方案,所以我会将此留给任何还在寻找的人。
React Native源代码中有一个function,可让您确定显示的视图控制器。好像他们在ActionSheetIOS模块中使用了它(请参阅此line)。要在您自己的本机模块中使用它,请添加以下内容:
nil