Xamarin主页详细页面自动汉堡包

时间:2017-11-02 13:58:52

标签: android ios xamarin master-detail hamburger-menu

我有一个Xamarin'应用程序与主细节页面,我想在ios,android和uwp菜单上的汉堡包图标。

现在,我正在使用xamarin网站上的示例创建主详细信息页面。

在Android上,图标可见而不做任何事情: enter image description here

on ios(和UWP)不可见:

enter image description here

为什么在ios和UWP上有这种行为? 如何在所有三个平台上都有图标?

谢谢!

编辑:我没有包含任何图像,也没有包含android,ios和UWP。

1 个答案:

答案 0 :(得分:2)

我测试了代码,发现它是由外部CREATE TABLE [dbo].[v$source]( [theDb] [varchar](100) NULL, [theLineNo] [int] NULL, [theName] [varchar](1000) NULL, [theText] [varchar](8000) NULL, [theType] [varchar](100) NULL, [theCreateDate] [datetime] NULL, [theOrderNum] [int] NULL, [DateCreated] [datetime] NULL, [DateUpdated] [datetime] NULL ) ON [PRIMARY] CREATE TABLE [dbo].[v$source_unsplit]( [theDb] [varchar](100) NULL, [theName] [varchar](1000) NULL, [theText] [varchar](8000) NULL, [theType] [varchar](100) NULL, [theCreateDate] [datetime] NULL, [theOrderNum] [int] NULL, [DateCreated] [datetime] NULL, [DateUpdated] [datetime] NULL ) ON [PRIMARY] GO CREATE FUNCTION [dbo].[GetLHS] ( @p_delim varchar(1), @p_string varchar(max) ) RETURNS varchar(max) AS BEGIN declare @l_pos int; set @l_pos = charindex(@p_delim,@p_string,1); --if (@l_pos = 0) -- return @p_string; return substring(@p_string,1,iif(@l_pos=0,len(@p_string),@l_pos-1)); END CREATE FUNCTION [dbo].[GetRHS] ( @p_delim varchar(1), @p_string varchar(max) ) RETURNS varchar(max) AS BEGIN declare @l_pos int; set @l_pos = charindex(@p_delim,@p_string,1); if (@l_pos = 0) return ''; return substring(@p_string,@l_pos+1,len(@p_string)); END CREATE PROCEDURE sp_bld_v$source AS BEGIN delete from v$source_unsplit EXEC sp_MSforeachdb 'USE ?; insert into dict..v$source_unsplit (TheDB,TheName,TheText,TheType,TheCreateDate,TheOrderNum) SELECT ''?'' thedb, o.name, substring(c.Text,1,8000),xtype,crdate,colid FROM syscomments AS c INNER JOIN sysobjects AS o ON c.id = o.id' delete from v$source DECLARE @C_TEXT_CURSOR as CURSOR; DECLARE @l_thedb varchar(1000) DECLARE @l_thename varchar(1000) DECLARE @l_theordernum int DECLARE @l_text varchar(max) DECLARE @l_lhs varchar(max) = 'NULL' DECLARE @l_line_no int DECLARE @l_createDate datetime declare @l_thetype varchar(10) SET @C_TEXT_CURSOR = CURSOR FOR select theDb,TheName,theOrderNum,thetext,theCreateDate,thetype--,replace(theText,char(10),'@^@') from v$source_unsplit order by theDb,TheName,theOrderNum OPEN @C_TEXT_CURSOR; FETCH NEXT FROM @C_TEXT_CURSOR INTO @l_thedb,@l_thename,@l_theordernum,@l_text,@l_createDate,@l_thetype WHILE @@FETCH_STATUS = 0 BEGIN if @l_theordernum = 1 begin set @l_line_no = 1 if @l_lhs <> 'NULL' begin insert into v$source (TheDB,TheLineNo,TheName,TheText,TheType,TheCreateDate,TheOrderNum) select @l_thedb,@l_line_no,@l_thename,@l_lhs,@l_thetype,@l_createDate,@l_theordernum end end else begin set @l_text = @l_lhs+@l_text -- reconstuct previous line end while charindex(char(10),@l_text)>0 begin set @l_lhs = lib.dbo.GetLHS(char(10),@l_text) set @l_text = lib.dbo.GetRHS(char(10),@l_text) insert into v$source (TheDB,TheLineNo,TheName,TheText,TheType,TheCreateDate,TheOrderNum) select @l_thedb,@l_line_no,@l_thename,@l_lhs,@l_thetype,@l_createDate,@l_theordernum --print(@l_text) set @l_line_no = @l_line_no+1 end set @l_lhs = @l_text FETCH NEXT FROM @C_TEXT_CURSOR INTO @l_thedb,@l_thename,@l_theordernum,@l_text,@l_createDate,@l_thetype END CLOSE @C_TEXT_CURSOR; DEALLOCATE @C_TEXT_CURSOR; END GO 引起的。您目前正在NavigationPageMasterDetailPage嵌套,导致切换按钮消失。

因此,解决方案很简单,只需修改NavigationPage中的以下代码行:

LoginPage.xaml.cs

对此:

await Navigation.PushAsync(new MasterDetailAppPage());

<强>更新

在iOS中,默认情况下,xamarin不提供切换按钮图标,您需要在MasterPage上手动设置它。即在App.Current.MainPage = new MasterDetailAppPage();

MasterDetailAppPageMaster.xaml

将您的图标图像作为资源添加到iOS项目的Resources文件夹中。但我已经在你的项目中看到了<ContentPage ... Icon="hamburger.png" Title="{sgat:Translate appName}"> 。所以你可以直接使用它。